package cn.tedu.store.service;

import java.util.List;


import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import cn.tedu.store.entity.Address;

@RunWith(SpringRunner.class)
@SpringBootTest
public class AddressServiceTestCase {
	@Autowired
	private IAddressService service;
	
	@Test
	public void createAddress() {
		try {
			Address address = new Address();
			address.setUid(5);
			address.setName("小王");
			String username = "超级管理员";
			service.createAddress(address, username);
			System.err.println("OK");
		} catch (Exception e) {
			System.err.println(e.getClass().getName());
			System.err.println(e.getMessage());
		}
		
	}
	
	@Test
	public void getByUid() {
		try {
			List<Address> data = service.getByUid(22);
			System.err.println("begin");
			for(Address item:data) {
				System.err.println(item);
			}
			System.err.println("end");
		} catch (Exception e) {
			System.err.println(e.getClass().getName());
			System.err.println(e.getMessage());
		}
	}
	
	@Test
	public void setDefault() {
		try {
			Integer uid=28;
			Integer aid=32;
			String username="朱上林";
			service.setDefault(aid, uid, username);
			System.err.println("OK");
		} catch (Exception e) {
			System.err.println(e.getClass().getName());
			System.err.println(e.getMessage());
		}
		
	}
	
	@Test
	public void delete() {
		try {
			Integer aid=33;
			Integer uid=28;
			String username="ROOT";
			service.delete(aid, uid, username);
			System.err.println("地址删除成功");
		} catch (Exception e) {
			System.err.println(e.getClass().getName());
			System.err.println(e.getMessage());
		}
	}
}
